package com.example.cmpe277stockdata;

import com.example.cmpe277stockdata.beans.UserBean;
import com.example.cmpe277stockdata.constants.DataConstants;

import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

public class InitialTabContent extends TabActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_initial_tab_content);
		
		Resources res = getResources();
		TabHost tabHost = getTabHost(); 
		
		UserBean result = (UserBean) getIntent().getSerializableExtra(DataConstants.USER_DATA);
				
		// Real Time tab
		Intent intentRealTime = new Intent().setClass(this, LandingActivity.class);
		intentRealTime.putExtra(DataConstants.USER_DATA, result);
		TabSpec tabSpecRealTime = tabHost
		  .newTabSpec("Real Time Data")
		  .setIndicator("", res.getDrawable(R.drawable.home))
		  .setContent(intentRealTime);

		
		// Portfolio tab
		Intent intentPortfolio = new Intent().setClass(this, PortfolioActivity.class);
		intentPortfolio.putExtra(DataConstants.USER_DATA, result);
		//tabHost
		TabSpec tabSpecFavorite = tabHost
		  .newTabSpec("Favorite Company List")
		  .setIndicator("", res.getDrawable(R.drawable.filled_star))
		  .setContent(intentPortfolio);
	
		
		// add all tabs 
		tabHost.addTab(tabSpecRealTime);
		tabHost.addTab(tabSpecFavorite);
		
		//set nearby tab as default (zero based)
		tabHost.setCurrentTab(0);
	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.initial_tab_content, menu);
		return true;
	}

}
